package cz.muni.fi.pa165.sme.api;

import java.util.List;

import cz.muni.fi.pa165.sme.api.to.UserTO;

/**
 * @author forman
 */
public interface UserService {

	/**
	 * Create a new user in the database
	 *
	 * @param userTO new user
	 */
	public void createUser(UserTO userTO);

	/**
	 * Update a user in the database
	 *
	 * @param userTO updated user
	 */
	public void updateUser(UserTO userTO);

	/**
	 * Returns the UserTO with specified ID
	 *
	 * @param id id of the UserTO to return
	 * @return UserTO
	 */
	public UserTO getUserTO(Long id);

	/**
	 * Deletes the UserTO given as an argument to the method from the database
	 *
	 * @param userTO UserTO to be deleted
	 */
	public void deleteUserTO(UserTO userTO);

	/**
	 * returns a list of all UserTOs within the database
	 *
	 * @return list of all UserTOs
	 */
	public List<UserTO> findAllUserTO();


	/**
	 * Check existnece in the database. Provided input cannot be null.
	 *
	 * @param userTO to be checked for existence
	 * @return true if in database, false if either not there or if id is null
	 */
	boolean exists(final UserTO userTO);

	/**
	 * Checks provided object for references. Provided input cannot be null.
	 * @param userTO to be checked
	 * @return true if referenced, false if no references found or if id is null or input is not in the storage
	 */
	boolean isReferenced(final UserTO userTO);

	/**
	 * Checks the provided username; if it is already in use, returns false, true otherwise.
	 * @param login username to be checked
	 * @return true if username is available to use, false otherwise
	 */
	boolean isLoginAvailable(final String login);

	/**
	 * Returns the first user based on the provided login.
	 * @param login username
	 * @return user found, or null if the username is not in the database
	 */
	UserTO findUserByLogin(final String login);
}
